package com.teradyne.merlin2.ui.client.activities;

import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceController;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.teradyne.merlin2.ui.client.places.WorkListActivePlace;
import com.teradyne.merlin2.ui.client.places.WorkListApprovedPlace;
import com.teradyne.merlin2.ui.client.places.WorkListClosedPlace;
import com.teradyne.merlin2.ui.client.places.WorkListPlace;
import com.teradyne.merlin2.ui.client.presenter.BasePresenter;
import com.teradyne.merlin2.ui.client.views.WorkListMenuView;

public class WorkListMenuActivity extends AbstractActivity implements WorkListMenuView.Presenter, ActivityCustom {

	private final WorkListMenuView view;
	private final PlaceController placeController;
	private Place place;

	public WorkListMenuActivity(WorkListMenuView view, PlaceController placeController) {
		this.view = view;
		this.placeController = placeController;
	}

	@Override
	public void start(final AcceptsOneWidget container, final EventBus eventBus) {
		container.setWidget(view.asWidget());
		view.setPresenter(WorkListMenuActivity.this);
	}

	@Override
	public void onNewRequestsClicked() {
		placeController.goTo(new WorkListPlace());
	}

	@Override
	public void onActiveRequestsClicked() {
		placeController.goTo(new WorkListActivePlace());
	}

	@Override
	public void onApprovedRequestsClicked() {
		placeController.goTo(new WorkListApprovedPlace());
	}

	@Override
	public void onClosedRequestsClicked() {
		placeController.goTo(new WorkListClosedPlace());
	}

	@Override
	public void setPlace(Place place) {
		this.place = place;
	}

	@Override
	public Place getPlace() {
		return place;
	}

}